package com.tianji.promotion.annotation;

import com.tianji.common.autoconfigure.redisson.enums.LockType;
import com.tianji.promotion.enums.MyLockType;
import com.tianji.promotion.utils.MyLockStrategy;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * 用于标记被分布式锁锁住的方法
 * </p>
 *
 * @author lcm
 * @since 2023-08-05
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Lock {
    String name();

    long waitTime() default 1;

    long leaseTime() default -1;

    TimeUnit unit() default TimeUnit.SECONDS;

    MyLockType lockType() default MyLockType.RE_ENTRANT_LOCK;

    MyLockStrategy lockStrategy() default  MyLockStrategy.FAIL_AFTER_RETRY_TIMEOUT;
}
